package neu.soft.controller;

import neu.soft.entity.EntryOrder;
import neu.soft.service.impl.EntryOrderServiceImpl;
import neu.soft.vo.PageBean;
import neu.soft.vo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/entryOrder")
@RefreshScope
@CrossOrigin
public class EntryOrderController {
    @Autowired
    private EntryOrderServiceImpl entryOrderService;

    @RequestMapping("/addEntryOrder")
    public ResultBean<Integer> addEntryOrder(@RequestBody Map<String,Object> map){
        return entryOrderService.addEntryOrder(map);
    }

    /**
     * entryOrderId 入库单号
     * GROUP_CONCAT(code) as code 这一批入库的商品id
     * GROUP_CONCAT(num) as num 对应的商品数量
     * warehouseId 入库库房编号
     * inTime 入库时间
     * @param map
     * @return
     * @throws ParseException
     */
    @RequestMapping("/queryEntryOrder")
    public ResultBean<PageBean<Map<String,Object>>> queryEntryOrder(@RequestBody Map<String,Object> map) throws ParseException {
        return entryOrderService.queryEntryOrder(map);
    }

    @RequestMapping("/showAllEntryOrder")
    public ResultBean<PageBean<Map<String,Object>>> showAllEntryOrder(@RequestBody Map<String,Object> map) throws Exception {
        return entryOrderService.showAllEntryOrder(map);
    }

    @RequestMapping("/deleteEntryOrder")
    public ResultBean<Integer> deleteEntryOrder(@RequestBody Map<String,Object> map){
        return entryOrderService.deleteEntryOrder(map);
    }
}
